<?php
class Default_Form_ValidateComentTour {
	
	// save errors info
	protected $_messagesError = null;
	
	// save data after validate
	protected $_arrData;
	
	public function __construct($arrParam = array(),$options = null) {
		
		$validator = new Zend_Validate();
		
		// check content
		$str = strip_tags($arrParam['content']);
		$str = str_replace('&nbsp;', "", $str);
		$validator->addValidator(new Zend_Validate_NotEmpty(),true);
		if(!$validator->isValid($str)) {
			$message = $validator->getMessages();
			$this->_messagesError['content'] = 'Content: ' . current($message);
			$arrParam['content'] = '';
		} 
		
		// check title
	    $validator = new Zend_Validate();
		$validator->addValidator(new Zend_Validate_NotEmpty(),true);
	    if(!$validator->isValid($arrParam['title'])) {
			$message = $validator->getMessages();
			$this->_messagesError['title'] = 'Title: ' . current($message);
			$arrParam['title'] = '';
		} 
		
		// save data user type in the form
		$this->_arrData = $arrParam;
	}
	
	
	// check errors
	public function isError() {
		if(count($this->_messagesError) > 0) {
			return true;
		}else {
			return false;
		}
	}
	
	// get errors
	public function getMessageError() {
		return $this->_messagesError;
	}
	
	// get data
	public function getData() {
		return $this->_arrData;
	}
}